﻿@{
	ViewBag.Title = Resources.SysConferenceFunctionMaster + ConstValues.strDash + Resources.HuiTongCIS;
}
<div id="menuBar" style="height:35px;">
	<div style="float: left; padding: 5px 5px; font-weight: bold; text-align: left;">
		@Resources.FunctionName：<input id="selFunctionName" class="easyui-textbox" style="height:27px; width:200px;" />&nbsp;&nbsp;
		<a href="javascript:void(0);" class="easyui-linkbutton" iconcls="icon-search" onclick="searchData();">@Resources.Search</a>&nbsp;&nbsp;
	</div>
	<div class="clear"></div>
</div>
<div id="dataGrid"></div>

<form id="frmDetail" method="post">
	@Html.AntiForgeryToken()
	<input type="hidden" id="hidID" name="Id" />
	<input type="hidden" id="hidStatus" name="Status" />
</form>

@section Scripts {
<script>
	common.setCurrentMenu("SysConferenceFunctionMaster");

	$(function () {
		$("#selFunctionName").textbox("textbox").bind("keydown", function (e) {
			if (e.keyCode == 13) {
				searchData()
			}
		});

		$("#dataGrid").datagrid({
			url: "@Url.Action(nameof(SysConferenceFunctionMasterController.GetData),
					nameof(SysConferenceFunctionMasterController).GetControllerName())",
			method: "get",
			singleSelect: true,
			fitColumns: true,
			width: $(window).width() - 285,
			height: $(window).height() - 120,
			nowrap: false,
			pagination: true,
			pageSize: @ConstValues.DefaultGridRows,
			striped: true,
			toolbar: "#toolBar",
			pageSize: 100, 
			pageList: [100, 200, 300, 400, 500],
			columns: [[
				{ field: "id", hidden: true },
				@if ((User as ICISPrincipal).IsSSA ||
					Utility.HasSystemRole((User as ICISPrincipal), ConstValues.FunctionId.SysConferenceFunctionMaster, RoleType.修改))
				{
					<text>
					{
						field: "operate", title: "@Resources.Operate", align: "center", width: 150,
						formatter: function(value, rec) {
							if (rec.status == "@ConstValues.Status.正常") {
								return "<input type='checkbox' id='chk" + rec.id + "' style='height:25px; vertical-align:top;' onchange='editData(\""
									+ rec.id + "\",\"" + rec.status + "\")' checked/>"
							} else {
								return "<input type='checkbox' id='chk" + rec.id + "' style='height:25px; vertical-align:top;' onchange='editData(\""
									+ rec.id + "\",\"" + rec.status + "\")'/>"
							}
						}
					},
					</text>
				}
				{ field: "functionName", title: "@Resources.FunctionName", align: "center", sortable: true, width: 150 },
				{
					field: "status", title: "@Resources.Status", align: "center", sortable: true, width: 100,
					formatter: function(value, rec) {
						if (value== "@ConstValues.Status.正常") {
							return "@Resources.Normal"
						} else {
							return "@Resources.Pause"
						}
					}
				},
				{ field: "sort", title: "@Resources.Sort", align: "center", sortable: true, width: 100 },
				{ field: "remark", title: "@Resources.Remark", align: "center", sortable: true, width: 200 },
			]],
			onBeforeLoad: function(param) {
				param.random = Math.random();
			},
		});

		$(window).resize(function () {
			$("#dataGrid").datagrid("resize", {
				width: $(window).width() - 285,
				height: $(window).height() - 110
			});
		});
	});

	function searchData() {
		$("#dataGrid").datagrid("load", {
			SelFunctionName: $("#selFunctionName").textbox("getValue")
		});
	}

	function editData(id, status) {
		if (status == "@ConstValues.Status.正常") {
			status = "@ConstValues.Status.暂停";
		} else {
			status = "@ConstValues.Status.正常";
		}

		$("#hidID").val(id);
		$("#hidStatus").val(status);
		$.post("@Url.Action(nameof(SysConferenceFunctionMasterController.Modify),
				nameof(SysConferenceFunctionMasterController).GetControllerName())",
			$("#frmDetail").serialize(),
			function(data, textStatus, jqXHR) {
				if (data.result == "@ConstValues.AjaxFailResult") {
					common.showError(data.message);
				} else {
					common.showSuccess(data.message, true);
					$("#dataGrid").datagrid("reload");
				}
			}
		);
	};
</script>
}